import {createStore, applyMiddleware,compose} from 'redux'
import reducer from './reducer'
// 引入中间件
// import thunk from 'redux-thunk';
import thunk from 'redux-thunk';

// redux-devtools
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({trace: true}) || compose;

// 1.store dispatch 一般只支持对象不支持函数
// 2.action 中异步请求时 dispatch 需要接收一个函数 ，需要用到中间件
const store = createStore(
    reducer,
    // applyMiddleware(thunk)
    composeEnhancers(applyMiddleware(thunk))
);

export default store